<template>
	<view class="diamond-page">
		<z-paging ref="paging" v-model="dataList" @query="queryList">
			<view slot="top">
				<!-- #ifdef APP -->
				<u-navbar title="钻石明细" :autoBack="true" bgColor="transparent" :placeholder="true">></u-navbar>
				<!-- #endif -->
				<view class="tab-list">
					<view :class="tabsIndex==index?'tab-item active':'tab-item'" v-for="(item,index) in tabsList" :key="index" @click="tabsChange(index)">{{item.name}}</view>
				</view>
			</view>
			<view class="diamond-list">
				<view class="diamond-item" v-for="(item,index) in dataList" :key="index">
					<view class="item-left">
						<view class="title" v-if="tabsIndex==0">用户充值</view>
						<view class="title" v-if="tabsIndex==1">{{item.memo}}</view>
						<view class="time" v-if="tabsIndex==0">{{item.paytime_text}}</view>
						<view class="time" v-if="tabsIndex==1">{{item.createtime}}</view>
					</view>
					<view class="item-right">
						<view class="money" v-if="tabsIndex==0">{{item.real_amount}}</view>
						<view class="money" v-if="tabsIndex==1">{{item.money}}</view>
						<image class="diamond-icon" src="../../static/mine/icon_zs.png" />
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabsList: [{
					name: '充值记录',
					status: '1',
				}, {
					name: '消费记录',
					status: '2',
				}],
				tabsIndex: 0,
				dataList: [],
			}
		},

		methods: {
			tabsChange(index) {
				this.tabsIndex = index
				this.refreshList()
			},
			refreshList() {
				this.dataList = []
				this.$refs.paging.scrollToTop()
				this.$refs.paging.refresh();
			},
			queryList(pageNo, pageSize) {
				const apiFunction = this.tabsIndex == 0 ?
					this.$Api['user'].moneyRechargeList :
					this.$Api['user'].moneyLog;
				apiFunction({
					page: pageNo,
					limit: pageSize,
				}).then(res => {
					this.$refs.paging.complete(res.data.data);
				}).catch(res => {
					this.$refs.paging.complete(false);
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.diamond-page {
		width: 100%;
		min-height: 100vh;
		background-color: #ffffff;
		position: relative;


		.tab-list {
			min-height: 86rpx;
			margin: 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.tab-item {
				flex: 1;
				line-height: 86rpx;
				text-align: center;
				color: #A7A5A5;
			}

			.active {
				font-weight: bold;
				position: relative;
				color: #F169F6;
			}

			.active::after {
				content: '';
				position: absolute;
				width: 34rpx;
				height: 8rpx;
				left: 50%;
				transform: translateX(-50%);
				bottom: 0;
				background: #F169F6;
				box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(241, 105, 246, 0.5);
				border-radius: 4rpx;
			}
		}

		.diamond-list {
			margin: 0 40rpx;
			

			.diamond-item {
				display: flex;
				align-items: center;
				align-self: center;
				margin-bottom: 20rpx;
				box-sizing: border-box;
				padding: 22rpx 28rpx;
				background: #F7F7F7;
				border-radius: 16rpx;
				.item-left {
					flex: 1;
					text-align: left;

					.title {
						font-weight: bold;
						font-size: 30rpx;
					}

					.time {
						margin-top: 10rpx;
						font-size: 26rpx;
						color: #9A9A9A;
					}
				}

				.item-right {
					color: #000000;
					display: flex;
					align-items: center;
					.diamond-icon {
						width: 34rpx;
						height: 34rpx;
						margin-left: 10rpx;
						margin-top: 0rpx;
					}
					.money {
						font-size: 30rpx;
					}
				}
			}

		}
	}
</style>